package com.gitee.feizns.explore.data_structure.hashtable;

import java.util.HashMap;
import java.util.Map;

/**
 * @author feizns
 * @since 2020/3/2
 */
public class UniqueOccurrences {

    public boolean uniqueOccurrences(int[] arr) {
        Map<Integer, Integer> m = new HashMap<>();
        for(int x : arr) {
            Integer n = m.get(x);
            if ( n == null )
                n = 0;
            m.put(x, n + 1);
        }

        m.values().stream().distinct().count();
        for(Map.Entry<Integer, Integer> e : m.entrySet()) {
            if ( e.getValue() > 1 )
                return false;
        }
        return true;
    }

}
